package cn.wzx.dao;

import cn.wzx.entity.Boke;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;

@Repository
public class BokeDaoImpl implements BokeDao {
    @Autowired
    MongoTemplate mongoTemplate;

    @Override
    public String add(Boke boke) {
        Boke b = mongoTemplate.insert(boke);
        return b.getId();
    }

    @Override
    public Boke findOneBody(String bokeid) {
        Query query = new Query(Criteria.where("id").is(bokeid));
        return mongoTemplate.findOne(query,Boke.class);
    }
}
